<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>管理后台</title>
</head>

<body>
  <div class="page">
    <% include components/top.inc.ejs %>
    <div class="right-wrap">
      <div>
        <div style="float: left; width: 50%;">
          <form action="?" method="post">
              <p>标题：<input type="text" name="title" /></p>
              <p>描述：<textarea name="description"></textarea></p>
              <p>链接：<input type="text" name="href" /></p>
              <p><input type="submit" value="添加" /></p>
          </form>
        </div>      
        <% if (typeof mod_data !== 'undefined') { %>
          <div style="float: left; width: 50%;">
            <form action="?" method="post">
              <input type="hidden" name="mod_id" value="<%= mod_data.id %>" />
              <p>标题：<input type="text" name="title" value="<%= mod_data.title %>" /></p>
              <p>描述：<textarea name="description"><%= mod_data.description %></textarea></p>
              <p>链接：<input type="text" name="href" value="<%= mod_data.href %>" /></p>
              <p><input type="submit" value="修改" /></p>
            </form>
          </div>
        <% } %>
        <div style="clear: both"></div>
      </div>
      <table border="1" width="90%">        
        <tbody>
          <tr>
            <th>ID</th>
            <th>标题</th>
            <th>描述</th>
            <th>链接</th>
            <th>操作</th>
          </tr>
        </tbody>
        <tbody>
          <% for (var i=0; i<banners.length; i++) { %>
          <tr>
            <td><%= banners[i].id %></td>
            <td><%= banners[i].title %></td>
            <td><%= banners[i].description %></td>
            <td><%= banners[i].href %></td>
            <td>
              <a href="?act=mod&id=<%= banners[i].id %>">修改</a>
              |
              <a href="?act=del&id=<%= banners[i].id %>" onclick="return confirm('你真的要删吗？')">删除</a>
            </td>
          </tr>
          <% } %>          
        </tbody>
      </table>
    </div>
  </div>
</body>

</html>